#include <iostream>
using namespace std;
class Complex
{
public:
    Complex(double r=0,double i=0):re(r),im(i) {}

    void print() const
    {
        cout<< re <<" + " << im <<"i\n";
    }

    Complex& add_assignment(const Complex& cm)// +=
    {
        re+=cm.re;
        im+=cm.im;
        return *this;
    }

    Complex neg() // -
    {
        return Complex(-re, -im );
    }

    Complex add(const Complex&  cm2) //+ 
    {
        Complex cm;
        cm.re = this->re + cm2.re;
        cm.im = this->im + cm2.im;
        return cm;
    }

private:
    double re;
    double im; 
};

int main()
{
    Complex cm1(1.5,-2.3),cm2(3.3,8.7),cm3,cm4,cm5(1);
    cm3 = cm1.neg();
    cm3.print();
    cm4 = cm1.add(cm2);
    cm4.print();
    cm2.add_assignment(cm1);
    cm2.print();
    cm5.add_assignment(cm4.add_assignment(cm3));
    cm5.print();
    return 0;
}
